import { Alova } from '@/utils/http/alova/index';
import { Config } from '../config';

export interface SerialConfig {
  uartBaudrate0: number;
  uartIp0: string;
  uartMode0: number;
  uartPort0: number;
  uartPortB0: number;
  uartSbus0: boolean;
  uartSbusInterval0: number;

  uartBaudrate1: number;
  uartIp1: string;
  uartMode1: number;
  uartPort1: number;
  uartPortB1: number;
  uartSbus1: boolean;
  uartSbusInterval1: number;

  uartBaudrate2: number;
  uartIp2: string;
  uartMode2: number;
  uartPort2: number;
  uartPortB2: number;
  uartSbus2: boolean;
  uartSbusInterval2: number;
}

//获取串口参数
export function getSerialConfig() {
  return Alova.Get<Config>('/config', {
    meta: {
      isReturnNativeResponse: true, // 关键配置, 返回原生响应头
    },
  });
}

// 更新串口配置
export function updateSerialConfig(data) {
  //console.log(data);
  return Alova.Post<string>('/config', data, {
    meta: {
      isReturnNativeResponse: true, // 关键配置, 返回原生响应头
    },
  });
}
